#!/usr/bin/python
# -*- coding: UTF-8 -*-

from kpautos.engine.case import Case
from kptest.config.enum import DeviceType, HostType, DeviceUtility


class BMC_SSH_010(Case):
    """
        Name:
            BMC_SSH_010
        Label:
            查看存储信息
        PreCondition:
            1、BMC正常运行
        TestStep:
            1.登录BMC
            2.查看RAID信息，有结果A）
            iBMC:/->ipmcget -t storage -d ctrlinfo -v all
            3.查看逻辑盘信息，有结果B）
            iBMC:/->ipmcget -t storage -d ldinfo -v 0 all
            4.查看硬盘信息，有结果C）
            iBMC:/->ipmcget -t storage -d pdinfo -v all
        ExpectedResult:
            A）RAID卡正常显示
            B）逻辑盘正常显示
            C）硬盘正常显示
        Parameters:

        Remark:

    """

    # 测试执行前配置等准备操作
    def pre_test_case(self):
        self.device_dut = self.resource.get_device(device_type=DeviceType.Server, utility=DeviceUtility.DUT)
        self.bmc_host = self.device_dut.get_host(host_type=HostType.BMC)

    # 测试步骤
    def procedure(self):
        self.log_step("1、查看RAID卡信息")
        resp = self.bmc_host.run({"command": ["ipmcget -t storage -d ctrlinfo -v all"], "timeout": 3})
        self.log_info(resp)
        if resp['rc'] != 0:
            self.assertIsNotNone(None, f"{resp['stderr']}")
        self.log_step("2、查看逻辑盘信息")
        resp = self.bmc_host.run({"command": ["ipmcget -t storage -d ldinfo -v 0 all"], "timeout": 3})
        self.log_info(resp)
        if resp['rc'] != 0:
            self.assertIsNotNone(None, f"{resp['stderr']}")
        self.log_step("3、查看物理盘信息")
        resp = self.bmc_host.run({"command": ["ipmcget -t storage -d pdinfo -v all"], "timeout": 3})
        self.log_info(resp)
        if resp['rc'] != 0:
            self.assertIsNotNone(None, f"{resp['stderr']}")

    # 测试结束后恢复环境
    def post_test_case(self):
        pass